home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kellogg's Amérique
/
Kellogg's Amérique
/
super_quizz.swf
/
scripts
/
jeux
/
SuperQuiz.as
< prev
Wrap
Text File
|
2020-08-04
|
5KB
|
173 lines
package jeux
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
public class SuperQuiz extends Jeu
{
public var mascotte:MovieClip;
public var current_question:int;
public var quizz2:MovieClip;
public var quizz5:MovieClip;
public var quizz7:MovieClip;
public var quizz8:MovieClip;
public var quizz9:MovieClip;
public var quizz4:MovieClip;
public var quizz6:MovieClip;
public var quizz3:MovieClip;
public var chargement:MovieClip;
public var quizz1:MovieClip;
public var bonne:Boolean;
public var score:Score;
public var quizz10:MovieClip;
public var timer_question:Timer;
public var n_page:TextField;
public var secondechance:Boolean = false;
public var page_resultat:MovieClip;
public function SuperQuiz()
{
secondechance = false;
timer_question = new Timer(2500,1);
super();
pages = [chargement,quizz1,quizz2,quizz3,quizz4,quizz5,quizz6,quizz7,quizz8,quizz9,quizz10,page_resultat];
jouer();
page_resultat.btn_jouer.addEventListener(MouseEvent.CLICK,clic_bouton);
mascotte.gotoAndStop(1);
n_page.text = "1";
}
override public function toString() : String
{
return "SuperQuiz";
}
override public function quitter() : *
{
current_question = 0;
score.score = 0;
}
override public function jouer() : *
{
mascotte.gotoAndStop(1);
mascotte.visible = true;
bonne = true;
score.score = 0;
current_question = 0;
_next_question();
}
public function _repondre(param1:int) : void
{
var _loc2_:* = undefined;
if(timer_question.running)
{
return;
}
trace("_repondre " + param1 + " / " + DataSuperQuiz.reponses[current_question]);
_loc2_ = this["quizz" + String(current_question)];
if(DataSuperQuiz.reponses[current_question] == param1)
{
trace("reponse juste");
if(bonne)
{
score.score += 1;
}
bonne = true;
mascotte.gotoAndStop(2);
_loc2_.question.gotoAndStop(40);
}
else
{
trace("reponse fausse");
bonne = false;
if(secondechance)
{
mascotte.gotoAndStop(3);
}
else
{
mascotte.gotoAndStop(3);
}
_loc2_.question.gotoAndStop(80);
}
timer_question.addEventListener(TimerEvent.TIMER_COMPLETE,_next_question);
timer_question.start();
}
public function _next_question(param1:TimerEvent = null) : *
{
var _loc2_:* = undefined;
trace(bonne + "-" + current_question + "-" + (DataSuperQuiz.reponses.length - 1));
if(bonne)
{
++current_question;
secondechance = false;
}
else
{
secondechance = true;
}
mascotte.gotoAndStop(1);
if(current_question >= DataSuperQuiz.reponses.length)
{
finjeu();
return;
}
n_page.text = String(current_question);
_loc2_ = this["quizz" + String(current_question)];
hide_all_but(_loc2_);
_loc2_.question.gotoAndStop(1);
_loc2_.btn1.clicAction = _repondre;
_loc2_.btn2.clicAction = _repondre;
_loc2_.btn3.clicAction = _repondre;
}
public function finjeu() : void
{
if(fin != null)
{
fin(score.score);
}
hide_all_but(page_resultat);
mascotte.visible = false;
if(score.score >= 9)
{
page_resultat.bravo1.points.text = score.score;
page_resultat.dommage.visible = false;
page_resultat.bravo1.visible = true;
}
else
{
page_resultat.dommage.points.text = score.score;
page_resultat.dommage.visible = true;
page_resultat.bravo1.visible = false;
}
}
}
}